package com.guochenglang.www.dao.impl;

import com.guochenglang.www.dao.LikesDao;
import com.guochenglang.www.pojo.Likes;
import com.guochenglang.www.util.GetTable;
import com.guochenglang.www.util.connect.JdbcUtil;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * 点赞表的Dao层
 *
 * @author 郭程朗
 */
public class LikesDaoImpl implements LikesDao {
    /**
     * 表名
     */
    private static final String TABLE = GetTable.getTable(Likes.class);

    public LikesDaoImpl() {
    }

    @Override
    public ArrayList<Likes> likesSelect(Likes likes) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectMax(TABLE, likes);
    }

    @Override
    public ArrayList<Likes> likesSelectByLimit(int page, int num, Likes likes, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectByLimit(TABLE, page, num, likes, order, mode);
    }


    @Override
    public int insertLikes(Likes likes) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.insert(TABLE, likes);
    }

    @Override
    public int updateLikes(Likes set, Likes conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.update(TABLE, set, conditions);
    }

    @Override
    public int deleteLikes(Likes likes) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.delete(TABLE, likes);
    }
}
